<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="java.util.*" %>
<%@ page import="org.news.entity.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>文件管理</title>
<%
    List<file> files=(List<file>)request.getAttribute("allFiles");
    manager mg=(manager) session.getAttribute("user"); 
    Object a1=request.getParameter("quit");
    if("t".equals(a1) ||mg==null){  //点击退出或者未登录状态
   	 session.removeAttribute("user");
   	 //将mg置为空，否则报空指针异常
   	 mg=new manager(null,null,null);
    }
%>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/file.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/oneNew.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.3.1.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/particles.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/file.js"></script>
<style type="text/css">
.background {
 			position: absolute;
 			display: block;
 			top: 0;
 			left: 0;
 			z-index: 0;
 		}
</style>
</head>
<body>
<!-- 页面头部   -->
<header id="header_div">
  <div class="container">
	<div class="logo left">
		<img src="${pageContext.request.contextPath}/img/logo2.jpg" width="700" height="90">
	</div>
	<ul class="right">
	    <li id="info1"><a href="${pageContext.request.contextPath}/view/login/login.jsp">登录？</a></li>
	    <li id="info2"><a href="${pageContext.request.contextPath}/view/login/addMg.jsp">马上注册</a></li>
		<li><a href="${pageContext.request.contextPath}/view/News/addNew.jsp">添加新闻</a></li>
		<li><a href="${pageContext.request.contextPath}/newsServlet/seleByPage/1">查询全部新闻</a></li>
		<li><a href="${pageContext.request.contextPath}/index.jsp">返回主页</a></li>
	</ul>
  </div>
</header>
<!-- 文件上传 -->
<div id="upLoad"> 
    <h3 align="center">上传文件</h3>
	<form action="" method="post"  enctype="multipart/form-data">
		<p><input type="file" name="file" id="file" /></p>
		<p>描述:<input name="desc" type="text" id="desc"/>	</p>	
	</form>
	<button onclick="uploadFile()">上传文件</button>
</div>
<br>
<br>
<!-- 表格 -->
<div id="table_div">
	<table class="gridtable" id="table">
		<tr>
  		  <th>编号</th>
   		  <th>文件名</th>
    	  <th>文件描述</th>
   		  <th>上传时间</th>
    	  <th>操作</th>
		</tr>
		<%  for(file f:files){ %>
		<tr>
    		<td><%=f.getFid() %></td>
    		<td><%=f.getFname() %></td>
    		<td><%=f.getFdesc() %></td>
    		<td><%=f.getFtime() %></td>
    		<td>
    			<button><a href="/NewsManager_SSM/upAndDownServlet/download?fileName=<%=f.getFname()%>">下载</a></button>
    			<button>修改</button>
    			<button onclick="dele(<%=f.getFid()%>)">删除</button>
    		</td>
		</tr>
			<% }%>
	</table>
</div>
<!--页脚部分-->
<div id="footer">
	<div class="container">
		<p>
			<img src="img/i-f-logo.png"> <span>@2020 北京市xxxxxxx</span>
			 <a href="#">版权说明</a> <a href="#">版权说明</a> <a href="#">版权说明</a> 
			 <a href="#">版权说明</a> <a href="#">版权说明</a>
		</p>
	</div>
</div>
<script type="text/javascript">
//进行登录判断
$(function () {
    var uname="<%=mg.getUname()%>";
    var uid="<%=mg.getId()%>";
    //判断用户名是否为空
    if(!isEmpty(uname)){
    	$("#info1").html("<span>欢迎您！&nbsp"+uname+"<a href='/NewsManager_SSM/index.jsp?quit=t'> [退出]</a></span>");
    	$("#info2").text("");
    }
});

</script>
</body>
</html>